package cn.tedu.sp04.order.feign;

import cn.tedu.sp01.pojo.Item;
import cn.tedu.web.util.JsonResult;
import org.springframework.stereotype.Component;

import java.util.Arrays;
import java.util.List;

@Component
public class ItemFeignClientFB implements ItemFeignClient {




    @Override
    public JsonResult<List<Item>> getItems(String orderId) {
        if (Math.random() < 0.5) {
            List<Item> items = Arrays.asList(new Item[]{
                    new Item(1, "缓存aaa", 2),
                    new Item(2, "缓存bbb", 1),
                    new Item(3, "缓存ccc", 3),
                    new Item(4, "缓存ddd", 1),
                    new Item(5, "缓存eee", 5)
            });

            return JsonResult.ok().data(items);
        }
        return JsonResult.err().msg("获取商品订单信息失败");
    }
        @Override
        public JsonResult<?> decreaseNumber (List < Item > items) {
            return JsonResult.err().msg("无法修改商品库存");
        }
    }
